package com.cn.项目.飞机预约管理系统.Maininterface;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SetFilght extends JPanel implements ActionListener {
    JPanel p3 = null;
    public SetFilght(){
        JPanel p1 = new JPanel();
        p1.setLayout(new BorderLayout());
        JPanel p2 = new JPanel();
        p1.add(p2,"North");
        p2.setLayout(new GridLayout(1,2,50,0));
        JButton j1 = new JButton("设置航班");
        j1.addActionListener(this);
        JButton j2 = new JButton("显示航班");
        j2.addActionListener(this);
        JButton j3 = new JButton("删除航班");
        j3.addActionListener(this);

        p2.add(j1);
        p2.add(j2);
        p2.add(j3);
        p3 = new JPanel();
        p1.add(p3,"Center");

        this.add(p1);
        this.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand()=="设置航班"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new Flight());
            p3.setVisible(true);
        }


        if (e.getActionCommand()=="显示航班"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new ShowFlight());

            p3.setVisible(true);
        }

        if (e.getActionCommand()=="删除航班"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new DeleteFlight());

            p3.setVisible(true);
        }

    }

}
